package loja.dao.impl.hibernate;

import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import loja.dao.conta.ContaAbstrataDAO;
import loja.model.conta.ContaAbstrata;
import loja.model.conta.titular.Titular;

public class ContaAbstrataDAOHibernate implements ContaAbstrataDAO {

	private Session session;

	public ContaAbstrataDAOHibernate(Session session) {
		this.session = session;
	}

	@Override
	public ContaAbstrata consultarContaPorTitular(Titular titular) {
		if (titular == null)
			return null;
		return (ContaAbstrata) this.session.createCriteria(ContaAbstrata.class)
				.add(Restrictions.like("titular", titular)).uniqueResult();
	}
}
